package forms;

import classes.Conexao;
import classes.Usuarios;
import javax.swing.ImageIcon;
import javax.swing.JInternalFrame;

/**
 *
 * @author Yanni
 */
public class FormInicial extends javax.swing.JFrame {

    /**
     * Creates new form NewMDIApplication
     */
    
    public FormInicial() {
        initComponents();   
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        desktopPane = new javax.swing.JDesktopPane();
        lblBemVindo = new javax.swing.JLabel();
        menuPrincipal = new javax.swing.JMenuBar();
        menuComanda = new javax.swing.JMenu();
        menuAberturaComanda = new javax.swing.JMenu();
        menuAbrirComanda = new javax.swing.JMenuItem();
        menuFecharAberturaComanda = new javax.swing.JMenuItem();
        menuConsultarComanda = new javax.swing.JMenuItem();
        menuAtendimento = new javax.swing.JMenu();
        menuIniciarAtendimento = new javax.swing.JMenuItem();
        menuConsultarAtendimento = new javax.swing.JMenuItem();
        jMenuItem2 = new javax.swing.JMenuItem();
        menuMesa = new javax.swing.JMenu();
        menuAberturaMesa = new javax.swing.JMenu();
        menuAbrirMesa = new javax.swing.JMenuItem();
        jMenuItem1 = new javax.swing.JMenuItem();
        menuFecharAberturaMesa = new javax.swing.JMenuItem();
        menuConsultarMesa = new javax.swing.JMenuItem();
        menuProduto = new javax.swing.JMenu();
        menuServico = new javax.swing.JMenu();
        menuUsuario = new javax.swing.JMenu();
        menuFuncionario = new javax.swing.JMenu();
        menuSair = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Kuka & Beludo Snooker Bar - Menu Principal");
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        lblBemVindo.setFont(new java.awt.Font("Tahoma", 0, 18));
        lblBemVindo.setForeground(new java.awt.Color(255, 255, 255));
        lblBemVindo.setBounds(40, 40, 260, 40);
        desktopPane.add(lblBemVindo, javax.swing.JLayeredPane.DEFAULT_LAYER);

        menuComanda.setText("Comanda");
        menuComanda.setToolTipText("Comanda");

        menuAberturaComanda.setText("Abertura");
        menuAberturaComanda.setToolTipText("Abertura");

        menuAbrirComanda.setText("Abrir");
        menuAbrirComanda.setToolTipText("Abrir");
        menuAbrirComanda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuAbrirComandaActionPerformed(evt);
            }
        });
        menuAberturaComanda.add(menuAbrirComanda);

        menuFecharAberturaComanda.setText("Fechar");
        menuFecharAberturaComanda.setToolTipText("Fechar");
        menuFecharAberturaComanda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuFecharAberturaComandaActionPerformed(evt);
            }
        });
        menuAberturaComanda.add(menuFecharAberturaComanda);

        menuComanda.add(menuAberturaComanda);

        menuConsultarComanda.setText("Acessar");
        menuConsultarComanda.setToolTipText("Consultar");
        menuConsultarComanda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuConsultarComandaActionPerformed(evt);
            }
        });
        menuComanda.add(menuConsultarComanda);

        menuPrincipal.add(menuComanda);

        menuAtendimento.setText("Atendimento");
        menuAtendimento.setToolTipText("Atendimento");

        menuIniciarAtendimento.setText("Iniciar");
        menuIniciarAtendimento.setToolTipText("Iniciar");
        menuIniciarAtendimento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuIniciarAtendimentoActionPerformed(evt);
            }
        });
        menuAtendimento.add(menuIniciarAtendimento);

        menuConsultarAtendimento.setText("Consultar");
        menuConsultarAtendimento.setToolTipText("Consultar");
        menuConsultarAtendimento.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuConsultarAtendimentoActionPerformed(evt);
            }
        });
        menuAtendimento.add(menuConsultarAtendimento);

        jMenuItem2.setText("Encerrar");
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        menuAtendimento.add(jMenuItem2);

        menuPrincipal.add(menuAtendimento);

        menuMesa.setText("Mesa");
        menuMesa.setToolTipText("Mesa");

        menuAberturaMesa.setText("Abertura");
        menuAberturaMesa.setToolTipText("Abertura");

        menuAbrirMesa.setText("Abrir");
        menuAbrirMesa.setToolTipText("Abrir");
        menuAbrirMesa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuAbrirMesaActionPerformed(evt);
            }
        });
        menuAberturaMesa.add(menuAbrirMesa);

        jMenuItem1.setText("Consultar");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        menuAberturaMesa.add(jMenuItem1);

        menuFecharAberturaMesa.setText("Fechar");
        menuFecharAberturaMesa.setToolTipText("Fechar");
        menuFecharAberturaMesa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuFecharAberturaMesaActionPerformed(evt);
            }
        });
        menuAberturaMesa.add(menuFecharAberturaMesa);

        menuMesa.add(menuAberturaMesa);

        menuConsultarMesa.setText("Acessar");
        menuConsultarMesa.setToolTipText("Consultar");
        menuConsultarMesa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuConsultarMesaActionPerformed(evt);
            }
        });
        menuMesa.add(menuConsultarMesa);

        menuPrincipal.add(menuMesa);

        menuProduto.setText("Produto");
        menuProduto.setToolTipText("Produto");
        menuProduto.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                menuProdutoMouseClicked(evt);
            }
        });
        menuPrincipal.add(menuProduto);

        menuServico.setText("Serviço");
        menuServico.setToolTipText("Serviço");
        menuServico.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                menuServicoMouseClicked(evt);
            }
        });
        menuPrincipal.add(menuServico);

        menuUsuario.setText("Usuário");
        menuUsuario.setToolTipText("Usuário");
        menuUsuario.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                menuUsuarioMouseClicked(evt);
            }
        });
        menuPrincipal.add(menuUsuario);

        menuFuncionario.setText("Funcionário");
        menuFuncionario.setToolTipText("Funcionário");
        menuFuncionario.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                menuFuncionarioMouseClicked(evt);
            }
        });
        menuPrincipal.add(menuFuncionario);

        menuSair.setText("Sair");
        menuSair.setToolTipText("Sair");
        menuSair.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                menuSairMouseClicked(evt);
            }
        });
        menuPrincipal.add(menuSair);

        setJMenuBar(menuPrincipal);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(desktopPane, javax.swing.GroupLayout.DEFAULT_SIZE, 596, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(desktopPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 411, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    //Insere o internal frama no desktop
    public void adicionarJInternalFrame(JInternalFrame frame)
    {
        frame.setVisible(true);
        frame.setFrameIcon(new ImageIcon(getClass().getResource("/imagens/icon.png")));
        desktopPane.add(frame);
    }
    
    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        this.setIconImage(new ImageIcon(getClass().getResource("/imagens/icon.png")).getImage());   
        setExtendedState(MAXIMIZED_BOTH);  
        
        lblBemVindo.setText("Bem-vindo(a) " + Usuarios.nome + "!");            
    }//GEN-LAST:event_formWindowOpened

    private void menuConsultarComandaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuConsultarComandaActionPerformed
        FormSelecionarComanda fsc = new FormSelecionarComanda();
        adicionarJInternalFrame(fsc);
    }//GEN-LAST:event_menuConsultarComandaActionPerformed

    private void menuConsultarMesaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuConsultarMesaActionPerformed
        FormSelecionarMesa fsm = new FormSelecionarMesa();
        adicionarJInternalFrame(fsm);
    }//GEN-LAST:event_menuConsultarMesaActionPerformed

    private void menuAbrirComandaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuAbrirComandaActionPerformed
        FormAberturaComanda fac = new FormAberturaComanda();
        adicionarJInternalFrame(fac);
    }//GEN-LAST:event_menuAbrirComandaActionPerformed

    private void menuFecharAberturaComandaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuFecharAberturaComandaActionPerformed
        FormFecharComanda ffc = new FormFecharComanda();
        adicionarJInternalFrame(ffc);
    }//GEN-LAST:event_menuFecharAberturaComandaActionPerformed

    private void menuIniciarAtendimentoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuIniciarAtendimentoActionPerformed
        FormIniciarAtendimento fia = new FormIniciarAtendimento();
        adicionarJInternalFrame(fia);
    }//GEN-LAST:event_menuIniciarAtendimentoActionPerformed

    private void menuSairMouseClicked(java.awt.event.MouseEvent evt)//GEN-FIRST:event_menuSairMouseClicked
    {//GEN-HEADEREND:event_menuSairMouseClicked
        this.dispose();
        Usuarios.adm = false;
        Usuarios.nome = null;
        Usuarios.login = null;
        Conexao.desconectar();
        
        FormLogin fl = new FormLogin();
        fl.setVisible(true);
    }//GEN-LAST:event_menuSairMouseClicked

    private void menuProdutoMouseClicked(java.awt.event.MouseEvent evt)//GEN-FIRST:event_menuProdutoMouseClicked
    {//GEN-HEADEREND:event_menuProdutoMouseClicked
        FormSelecionarProduto fsp = new FormSelecionarProduto();
        adicionarJInternalFrame(fsp);
    }//GEN-LAST:event_menuProdutoMouseClicked

    private void menuServicoMouseClicked(java.awt.event.MouseEvent evt)//GEN-FIRST:event_menuServicoMouseClicked
    {//GEN-HEADEREND:event_menuServicoMouseClicked
        FormSelecionarServico fss = new FormSelecionarServico();
        adicionarJInternalFrame(fss);
    }//GEN-LAST:event_menuServicoMouseClicked

    private void menuUsuarioMouseClicked(java.awt.event.MouseEvent evt)//GEN-FIRST:event_menuUsuarioMouseClicked
    {//GEN-HEADEREND:event_menuUsuarioMouseClicked
        FormSelecionarUsuario fsu = new FormSelecionarUsuario();
        adicionarJInternalFrame(fsu);
    }//GEN-LAST:event_menuUsuarioMouseClicked

    private void menuFuncionarioMouseClicked(java.awt.event.MouseEvent evt)//GEN-FIRST:event_menuFuncionarioMouseClicked
    {//GEN-HEADEREND:event_menuFuncionarioMouseClicked
        FormSelecionarFuncionario fsf = new FormSelecionarFuncionario();
        adicionarJInternalFrame(fsf);
    }//GEN-LAST:event_menuFuncionarioMouseClicked

    private void menuConsultarAtendimentoActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_menuConsultarAtendimentoActionPerformed
    {//GEN-HEADEREND:event_menuConsultarAtendimentoActionPerformed
        FormConsultarAberturaComanda fca = new FormConsultarAberturaComanda();
        adicionarJInternalFrame(fca);
    }//GEN-LAST:event_menuConsultarAtendimentoActionPerformed

    private void menuAbrirMesaActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_menuAbrirMesaActionPerformed
    {//GEN-HEADEREND:event_menuAbrirMesaActionPerformed
        FormAberturaMesa fam = new FormAberturaMesa();
        adicionarJInternalFrame(fam);
    }//GEN-LAST:event_menuAbrirMesaActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        FormConsultarAberturaMesa fcam = new FormConsultarAberturaMesa();
        adicionarJInternalFrame(fcam);
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        FormFecharAberturaComanda ffac = new FormFecharAberturaComanda();
        adicionarJInternalFrame(ffac);
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void menuFecharAberturaMesaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuFecharAberturaMesaActionPerformed
        FormFecharAberturaMesa ffam = new FormFecharAberturaMesa();
        adicionarJInternalFrame(ffam);
    }//GEN-LAST:event_menuFecharAberturaMesaActionPerformed

    /**
     * @param args the command line arguments
     */
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JDesktopPane desktopPane;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JLabel lblBemVindo;
    private javax.swing.JMenu menuAberturaComanda;
    private javax.swing.JMenu menuAberturaMesa;
    private javax.swing.JMenuItem menuAbrirComanda;
    private javax.swing.JMenuItem menuAbrirMesa;
    private javax.swing.JMenu menuAtendimento;
    private javax.swing.JMenu menuComanda;
    private javax.swing.JMenuItem menuConsultarAtendimento;
    private javax.swing.JMenuItem menuConsultarComanda;
    private javax.swing.JMenuItem menuConsultarMesa;
    private javax.swing.JMenuItem menuFecharAberturaComanda;
    private javax.swing.JMenuItem menuFecharAberturaMesa;
    private javax.swing.JMenu menuFuncionario;
    private javax.swing.JMenuItem menuIniciarAtendimento;
    private javax.swing.JMenu menuMesa;
    private javax.swing.JMenuBar menuPrincipal;
    private javax.swing.JMenu menuProduto;
    private javax.swing.JMenu menuSair;
    private javax.swing.JMenu menuServico;
    private javax.swing.JMenu menuUsuario;
    // End of variables declaration//GEN-END:variables
}
